package com.test.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.ssm.dao.RoleDAO;
import com.test.ssm.pojo.Role;
import com.test.ssm.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDAO roleDAO;

    @Override
    public PageInfo<Role> getRoleList(Role role, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(roleDAO.getRoleList(role));
    }

    @Override
    public void addRole(Role role) {
        roleDAO.addRole(role);
    }

    @Override
    public void updateRole(Role role) {
        roleDAO.updateRole(role);
    }

    @Override
    public void deleteRole(Integer[] ids) {
        for (Integer id : ids) {
            roleDAO.deleteRole(id);
        }
    }

    @Override
    public Role getRoleById(Integer id) {
        return roleDAO.getRoleById(id);
    }
}
